﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="OsaNoue", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(OsaNoue))]
    public class OsaNoueSerializer : global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.KohustisSerializer {
        
        public OsaNoueSerializer(IOsaNoue clazz) : 
                base(clazz) {
        }
        
        protected new IOsaNoue clazz {
            get {
                return ((IOsaNoue)(base.clazz));
            }
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.TaodeldudMurdosa!=null) {
                Writer.WriteStartElement("TaodeldudMurdosa");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TaodeldudMurdosa))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MoistetudMurdosa!=null) {
                Writer.WriteStartElement("MoistetudMurdosa");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MoistetudMurdosa))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Noudeosa!=null) {
                Writer.WriteStartElement("Noudeosa");
                global::Xtee.Core.SerializationMetadata metaNoudeosa = this.GetMetaData(clazz.Noudeosa);
                Writer.WriteTypeAttribute(metaNoudeosa.TypeQualifiedName.Namespace, metaNoudeosa.TypeQualifiedName.Name);
                metaNoudeosa.NewSerializer(clazz.Noudeosa).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.OnRiigiOsaNoue!=null) {
                Writer.WriteStartElement("OnRiigiOsaNoue");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.OnRiigiOsaNoue))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Maksmiseinfo!=null) {
                Writer.WriteStartElement("Maksmiseinfo");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Maksmiseinfo))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="TaodeldudMurdosa") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TaodeldudMurdosa = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("TaodeldudMurdosa")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MoistetudMurdosa") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MoistetudMurdosa = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MoistetudMurdosa")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Noudeosa") {
                if ((Reader.IsElementNil() == false)) {
                    global::Xtee.Core.SerializationMetadata metaNoudeosa = this.GetMetaData<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.INoudeOsa>(Reader, "NoudeOsa", "http://producers.etoimik.xtee.riik.ee/producer/etoimik");
                    clazz.Noudeosa = metaNoudeosa.NewEntity<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.INoudeOsa>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("Noudeosa");
                        metaNoudeosa.NewSerializer(clazz.Noudeosa).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OnRiigiOsaNoue") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OnRiigiOsaNoue = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("OnRiigiOsaNoue")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Maksmiseinfo") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Maksmiseinfo = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Maksmiseinfo")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
